package arrays;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ArrayStringTest {

	/**
	 * @param args
	 */

	public static void main(String[] args) {
		// array 用法示例
//        String[] listReasons = new String[0];
//        String[] _rejectionReason = new String[] {""};
//        String[] _rejectionReason = new String[] {""};
        String [] _rejectionReason = new String[0];
        List<String> _rejectionReasonList = new ArrayList<String>();
        if(_rejectionReason.length == 1 && _rejectionReason[0].isEmpty() && !_rejectionReasonList.isEmpty()){
//            _rejectionReason = _rejectionReasonList.toArray(new String[_rejectionReasonList.size()]);
        }
        System.out.println(_rejectionReason.length + ", " + _rejectionReason[0].isEmpty() + ", " + _rejectionReasonList.isEmpty());
        System.exit(0);
//        System.out.println(listReasons.toString());
		
		byte [] bt1 = {61,62,63,64,66,67,68,65,69,90};  //简化写法
		byte [] bt2= new byte [] {1,2,3,4,5,6,7,8,9,10};   //复杂写法
		byte [] bt3 = new byte[5];  //只指定长度 的写法
        bt3 = bt2.clone();
        for (byte b : bt3) {
            System.out.print(b + "|");

        }

        for (byte t: bt1){
			System.out.print(t + ", "); 
		}
		System.out.println();


		Arrays.sort(bt1);
		for (byte t: bt1){
			System.out.print(t + ", "); 
		}
		System.out.println(); 
		
		System.out.println("index of 7 is: " + Arrays.binarySearch(bt1, (byte)7));
		
		// String, byte array
		String str = new String(bt1, Charset.forName("US-ASCII")); 
		System.out.println("aaa: " + str);
		
		// StringBuilder 
		StringBuilder sb = new StringBuilder("Hello"); 
		System.out.println(sb.toString() + "XXX" + ", capacity: " + sb.capacity());
		sb.setLength(50);
		System.out.println(sb.toString() + "XXX" + ", capacity: " + sb.capacity());
		
		// test Runtime
		
//		System.out.println("test runtime !");
//		Runtime rt = Runtime.getRuntime();
//		System.out.println("cpus: " + rt.availableProcessors());
//		try {
//			rt.exec("notepad.exe");
//		} catch (IOException e) {
//			e.printStackTrace();
//		}
		
		

	}

}
